package com.newtouch.serviceconsumer;


import io.github.resilience4j.bulkhead.annotation.Bulkhead;
import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;
import io.github.resilience4j.ratelimiter.annotation.RateLimiter;
import io.github.resilience4j.retry.annotation.Retry;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;


@FeignClient(name="service-hello-webflux")
@Component
public interface DemoServiceInterface {

    @GetMapping("/")
    @Bulkhead(name="sayHello", fallbackMethod = "helloFallback")
    @RateLimiter(name="sayHello", fallbackMethod = "helloFallback")
    @Retry(name="sayHello", fallbackMethod = "helloFallback")
    @CircuitBreaker(name="sayHello", fallbackMethod = "helloFallback")
    String sayHello();

    default String helloFallback(Throwable throwable) {
        return "service broken";
    }
}